// BAD CASE
type SingleUnion = any | never | unknown | void | null | undefined | 1 | 'a' | string
type U1 = SingleUnion extends 'a' ? true : false
type U2 = {
    [key in SingleUnion]: SingleUnion extends SingleUnion[key] ? true : false
}
// 联合类型在列举的时候，是没有顺序的

// Tuple based
type Singles = [any, never, unknown, void, null, undefined, 1, 'a', string, true, false]
type X = Omit<Singles, never>

type T1 = {
    [k in keyof Singles as ( // Singles is Tuple
        k extends symbol 
            ? never
            : k extends infer X extends string
                ? `${X}` extends `${number}`
                    ? k
                    : never
                : never
    )]: Singles[k] extends 'a' ? true : false
    // 当 any 在 extends 左侧的时候，会返回 true和false的联合类型即 boolean
}

type T2 = {
    [k in keyof Singles as (
        k extends string & `${number}`
            ? k
            : never
    )]: Singles[k] extends 'a' ? true : false
}

type T3 = {
    [k in keyof Singles as Extract<k, `${number}`>]: // `${number|'length'}`
        Singles[k] extends 'a' ? true : false
}

type T4 = {
    [k in keyof Singles]: k extends `${number}`
        ? Singles[k] extends 'a' ? true : false
        : Singles[k]
}

type MapT<T> = {
    [k in keyof T]: T[k]
}
type T7 = MapT<Singles>
type T71 = MapT<T4>

type MapTX<Source, T> = {
    [k in keyof Source]: k extends keyof T ? T[k]: Source[k]
}

type T72 = MapTX<Singles, T2> // Object To Tuple 对象成员类型转换为元祖列表

type MapMartix<Source> = {
    [k in keyof Source]: k extends `${number}`
        ? MapTX<Source, {
            [i in Extract<keyof Source, `${number}`>]:
                Source[k] extends Source[i] ? true: false
        }>
        : Source[k]
}
type T8 = MapMartix<Singles>
